using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class LoadTemplate : Acms.AcmsControls.TemplateLoaderPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override Acms.AcmsControls.TemplateLoaderControl GetLoaderControl()
    {
        return templateLoader;
    }

    protected override void OnPreInit(EventArgs e)
    {
        string theme = null;
        foreach (string key in Request.Form.AllKeys)
        {
            if (key.StartsWith("SelectTheme1"))
            {
                theme = "Theme1";
                break;
            }
            else if (key.StartsWith("SelectTheme2"))
            {
                theme = "Theme2";
                break;
            }
            else if (key.StartsWith("SelectTheme3"))
            {
                theme = "Theme3";
                break;
            }
            else if (key.StartsWith("SelectTheme4"))
            {
                theme = "Theme4";
                break;
            }
        }
        if (theme != null)
        {
            HttpCookie tmp = new HttpCookie("Theme");
            tmp.Value = theme;
            Response.Cookies.Add(tmp);
        }
        else
        {
            if (Request.Cookies["Theme"] != null)
            {
                theme = Request.Cookies["Theme"].Value;
            }
        }

        //if theme not set or not equal to allowed value set to theme1
        if (theme != "Theme1" && theme != "Theme2" && theme != "Theme3" && theme != "Theme4")
        {
            theme = "Theme1";
        }

        this.Theme = theme;

        base.OnPreInit(e);
    }

}
